// 专业管理

package basic

import (
	"api/common/web"
	"api/models"
	"net/http"
)

// @TagName 专业管理
// @Controller SpecialController
type SpecialController struct{}

// @Title 专业列表数据
// @Route /special/list --> List
// @Method post
func (this *SpecialController) List(w http.ResponseWriter, r *http.Request) {
	defer web.PanicHandler(w, r)
	inputJson, msg := web.TokenCheckRequest(r)
	if msg != nil {
		web.ServeJSON(w, msg)
		return
	}

	model := &models.Special{}
	web.JsonCallBakFilter(w, inputJson, model, "", "", "pid, sequ desc, id")
}

// @Title 专业下拉列表框数据
// @Route /special/listSelect --> ListSelect
// @Method post
func (this *SpecialController) ListSelect(w http.ResponseWriter, r *http.Request) {
	defer web.PanicHandler(w, r)
	inputJson, msg := web.TokenCheckRequest(r)
	if msg != nil {
		web.ServeJSON(w, msg)
		return
	}

	model := &models.Special{}
	fields := "id, pid, `name`, type"
	web.JsonCallBakFilter(w, inputJson, model, fields, "", "pid, sequ desc, id")
}

// @Title 新增专业信息
// @Route /special/create --> Create
// @Method post
func (this *SpecialController) Create(w http.ResponseWriter, r *http.Request) {
	defer web.PanicHandler(w, r)
	web.CreateRecord(w, r, &models.Special{})
}

// @Title 编辑专业信息
// @Route /special/edit --> Edit
// @Method post
func (this *SpecialController) Edit(w http.ResponseWriter, r *http.Request) {
	defer web.PanicHandler(w, r)
	web.EditRecord(w, r, &models.Special{})
}

// @Title 删除专业信息
// @Route /special/delete --> Delete
// @Method post
func (this *SpecialController) Delete(w http.ResponseWriter, r *http.Request) {
	defer web.PanicHandler(w, r)
	web.DeleteCallBak(w, r, &models.Special{})
}
